<?php 
	echo $this->Session->flash(); 
	echo $this->Session->flash('good');
	echo $this->Session->flash('bad');
?>
<div id="tabs">
	<ul>
		<li>
			<?php #echo $this->Html->link('General Infor', array('controller' => 'products', 'action' => 'loadProductForm')) ?>
			<a href="#tabs-1"><?php echo __('General Info') ?></a>
		</li>
		<?php if(isset($this->request->data['Product']['id'])){ ?>
			<li><?php echo $this->Html->link(__('Properties'), array('admin' => true, 'controller' => 'products', 'action' => 'loadProperties', $this->request->data['Product']['id'])); ?></li>
			<li><?php echo $this->Html->link(__('Images'), array('admin' => true, 'controller' => 'products', 'action' => 'loadImageForm', $this->request->data['Product']['id'])); ?></a></li>
			<li><?php echo $this->Html->link(__('Variant'), array('admin' => true, 'controller' => 'products', 'action' => 'loadVariantList', $this->request->data['Product']['id'])); ?></a></li>
		<?php }else{ ?>
			<li><a><?php echo __('Properties') ?></a></li>
			<li><a><?php echo __('Images') ?></a></li>
			<li><a><?php echo __('Variant') ?></a></li>
		<?php } ?>
	</ul>
<div id="tabs-1">
	<?php echo $this->Form->create('Product'); 
				echo $this->Form->hidden('id') ;
				echo $this->Form->hidden('Variant.0.id');?>
		<table class="form-table">
			<?php if(!isset($this->data['Product']['id'])){ ?>
			<tr>
				<td class='l-style'><?php echo __('Prototype') ?> <span class='star-rq'> * </span></td>
				<td class="r-style width_middle"><?php echo $this->Form->input('prototype_id', array('label' => false)); ?></td>
			</tr>
			<?php } ?>
			<tr>
				<td class='l-style'><?php echo __('Category') ?> <span class='star-rq'> * </span></td>
				<td class="r-style width_middle">
					<?php #echo $this->Form->input('Category', array('label' => false, 'multiple' => 'checkbox', 'type' => 'select')); ?>
					<?php echo $this->Form->input('Category', array('label' => false, 'type' => 'select', 'escape' => false)); ?>
				</td>
			</tr>
			<tr>
				<td class='l-style'><?php echo __('Name') ?> <span class='star-rq'> * </span></td>
				<td class="r-style width_middle"><?php echo $this->Form->input('name', array('label' => false, 'class' => 'required title-slug')); ?></td>
			</tr>
			<tr>
				<td class='l-style'><?php echo __('Short Description') ?> <span class='star-rq'> * </span></td>
				<td class="r-style width_full"><?php echo $this->Form->input('short_desc', array('label' => false, 'class' => 'required', 'cols' => 30, 'rows' => 4)); ?></td>
			</tr>
			<tr>
				<td class='l-style'><?php echo __('Description') ?> <span class='star-rq'> * </span></td>
				<td class="r-style width_full"><?php echo $this->Form->input('description', array('label' => false, 'class' => 'required mceEditor')); ?></td>
			</tr>
			<tr>
				<td class='l-style'><?php echo __('Available On') ?> <span class='star-rq'> * </span></td>
				<td class="r-style width_middle"><?php echo $this->Form->input('available_on', array('type' => 'text', 'label' => false, 'class' => 'required datepk')); ?></td>
			</tr>
			<tr>
				<td class='l-style'><?php echo __('Expires At') ?></td>
				<td class="r-style width_middle"><?php echo $this->Form->input('expires_at', array('type' => 'text', 'label' => false, 'class' => 'datepk')); ?></td>
			</tr>
			<tr>
				<td class='l-style'><?php echo __('Raw Price') ?> <span class='star-rq'> * </span></td>
				<td class="r-style width_middle"><?php echo $this->Form->input('Variant.0.raw_price', array('label' => false, 'class' => 'required digits')); ?></td>
			</tr>
			<tr>
				<td class='l-style'><?php echo __('Price') ?></td>
				<td class="r-style width_middle"><?php echo $this->Form->input('Variant.0.price', array('label' => false, 'class' => 'digits')); ?></td>
			</tr>
			<tr>
				<td class='l-style'><?php echo __('Hand On') ?> <span class='star-rq'> * </span></td>
				<td class="r-style width_middle"><?php echo $this->Form->input('hand_on', array('label' => false, 'class' => 'required digits')); ?></td>
			</tr>
			<tr>
				<td class='l-style'><?php echo __('Tags') ?></td>
				<td class="r-style width_middle"><?php echo $this->Form->input('tags', array('label' => false)); ?></td>
			</tr>
			<tr>
				<td class='l-style'><?php echo __('SEO Title') ?> <span class='star-rq'> * </span></td>
				<td class="r-style width_middle"><?php echo $this->Form->input('slug', array('label' => false, 'class' => 'required slug-string')); ?></td>
			</tr>
			<tr>
				<td class='l-style'><?php echo __('SEO Keywords') ?> <span class='star-rq'> * </span></td>
				<td class="r-style width_middle"><?php echo $this->Form->input('meta_keyword', array('label' => false, 'class' => 'required')); ?></td>
			</tr>
			<tr>
				<td class='l-style'>
					<?php echo __('SEO Description') ?> <span class='star-rq'> * </span></br>
					<span class="span-note"><?php echo __('Suggest 160 characters') ?></span>
				</td>
				<td class="r-style width_middle">
					<?php echo $this->Form->input('meta_desc', array('label' => false, 'class' => 'required', 'onkeyup' => 'count_character(this);')); ?>
					<p> <input type="text" id="count_chars" style="width: 40px !important; height: 20px; text-align:center;" disabled value="0" class="square-ipt" /> <?php echo __('words') ?></p>
				</td>
			</tr>
			<tr>
				<td class='l-style'><?php echo __('Status') ?></td>
				<td class="r-style width_middle"><?php echo $this->Form->input('status', array('label' => false, 'options' => $status)); ?></td>
			</tr>
			<tr>
				<td class='l-style no-border no-background'>
					(<span class='red-star'>*</span>) <?php echo __('Required') ?>
				</td>
				<td class='r-style actions no-border no-background'>
					<?php echo __($this->Form->submit(__('Save'), array('id' => 'submit_product'))); ?>
				</td>
			</tr>
		</table>
	<?php echo $this->Form->end(); ?>
</div>
</div> <!-- end #tabs -->
<?php $this->start('script') ?>
	<?php echo $this->Html->script('jquery.ui.core'); ?>
	<?php echo $this->Html->script('jquery.ui.widget'); ?>
	<?php echo $this->Html->script('jquery.ui.tabs'); ?>
	<?php echo $this->Html->script('jquery.ui.datepicker'); ?>
	<?php echo $this->Html->script('tiny_mce/tiny_mce'); ?>
	<?php echo $this->Html->script('tinymce.custom'); ?>
	<?php echo $this->Html->script('jquery.tagsinput.js'); ?>

	<script type="text/javascript">
		jQuery(document).ready(function(){
			jQuery(".datepk").datepicker({ dateFormat: 'yy-mm-dd' });
			jQuery('#ProductTags').tagsInput();


			$("#tabs" ).tabs({
				<?php echo isset($tab) ? "selected: " . $tab . "," : "" ?>
			  load: function (e, ui) {
			    $(ui.panel).find(".tab-loading").remove();
			  },
				beforeLoad: function( event, ui ) {
	    		var $panel = $(ui.panel);
			    if ($panel.is(":empty")) {
	    	    //$panel.append('<div class=\'tab-loading\'><?php echo $this->Html->image("ajax-loader.gif", array("alt" => __(""))) ?></br><?php echo __("Loading...") ?></div>')
			    }
					ui.jqXHR.error(function() {
						ui.panel.html('<?php echo __("Couldn\'t load this tab. We\'ll try to fix this as soon as possible. Please contact to Administrator.") ?> ');
					});
				}
			});
		});
	</script>
<?php $this->end(); ?>

<?php $this->start('css') ?>
	<?php echo $this->Html->css('themes/base/jquery.ui.all'); ?>
	<?php echo $this->Html->css('jquery.tagsinput'); ?>
<?php $this->end(); ?>
